<template>
	<view class="settings" @click="test()">
		<!-- #ifndef APP-PLUS -->
		<view>
			<view v-for="(item, index) in indexList" style="margin: 0 20rpx;" class="display_flex padding_tb_l u-border-bottom" :key="index" @click="toSrttins(item)">
				<view class="display_flex">
					<u-icon :name="item.icon" color="#2979ff" size="28" style="font-size: 28px !important;"></u-icon>
					<view>{{item.title}}</view>
				</view>
			</view>
			<!-- <view class="padding_tb_l display_column">
				<u-button type="info" @click="logout">退出登录</u-button>
			</view> -->
		</view>
		<!-- #endif -->

	</view>
</template>

<script>
	import {
		BASE_API
	} from '../../common/http/url'

	export default {
		name: "seettin",
		data() {
			return {
				indexList: [{
						id: 0,
						title: "编辑资料",
						icon: "edit-pen"
					}, {
						id: 1,
						title: "账号与安全",
						icon: "grid"
					}, {
						id: 2,
						title: "单位记录填写提示时间",
						icon: "calendar"
					}, {
						id: 3,
						title: "工作记录预设参数",
						icon: "file-text"
					}
					// ,{
					// 	id : 4,
					// 	title : "配置消防预警系统视频流",
					// 	icon : "scan"
					// },
				],
				urls: [],
				user: ""
			}
		},
		methods: {
			test() {
				console.log("page111111")
			},
			scrolltolower(res) {
				console.log(res)
			},
			logout() {
				uni.showModal({
					title: "提示",
					content: "您确定要退出吗？",
					success: (res) => {
						if (res.confirm) {
							let url = BASE_API + "pc/user/logout"
							let user = uni.getStorageSync("user")
							uni.request({
								header: {
									"Authorization": user.token,
									'Content-Type': 'application/x-www-form-urlencoded'
								},
								url: url,
								method: "POST",

							})
							uni.clearStorageSync()
							uni.clearStorage()

							//在起始页面跳转到test.vue页面并传递参数
							//在起始页面跳转到test.vue页面并传递参数
							uni.redirectTo({
								url: '/pages/login/login'
							});
							return
							// plus.runtime.restart();
						}
					}
				})
			},

			toSrttins(item) {
				console.log(11111)
				let id = item.id
				switch (id) {
					case 0: {
						uni.navigateTo({
							url: "/pagesMine/settting/editingData/editingData"
						})
						break
					}
					case 1: {
						uni.navigateTo({
							url: "/pagesMine/settting/accountSecurity/accountSecurity"
						})
						break
					}
					case 2: {
						if (this.user.power == 3) {
							uni.showToast({
								title: "权限不足",
								icon: "error"
							})
							return
						}
						uni.navigateTo({
							url: "/pagesMine/settting/timeToFill/timeToFill"
						})
						break
					}
					case 3: {
						uni.navigateTo({
							url: "/pagesMine/settting/PresetFeatureSettin/PresetFeatureSettin"
						})
						break
					}
					case 4: {
						uni.navigateTo({
							url: "/pagesMine/settting/fireEarlyWarning/fireEarlyWarning"
						})
						break
					}
				}
			}
		},
		onLoad() {
			let user = uni.getStorageSync("user")
			this.user = user
		}
	}
</script>

<style>
	.settings {
		width: 100%;
		height: auto;
	}
</style>